package com.xiaoxu.entry.bishi;

import java.util.ArrayList;
import java.util.List;

public class 找到数组中消失的数组448 {
    public static void main(String[] args) {
        int[] nums = {4,3,2,7,8,2,3,1};
        List change = change(nums);
        System.out.println(change.toString());
    }

    public static List change(int[] nums){
        int n = nums.length;
        if (nums == null) return null;
        for (int num : nums) {
            //找到需要修改的下标
            int x = (num - 1) % n;
            //修改该下标的值
            nums[x] += n;
        }
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < nums.length; i++) {
            //没出现过的元素
            if (nums[i] <= n){
                list.add(i + 1);
            }
        }
        return list;
    }
}
